/**
 * @author wanzhibao
 * @date 2018/12/05
 * @Description:暂时将几个页面api归入一起
*/
import fetch from '@/utils/fetch' // 拦截器
import until from '@/utils/until' // 引入公共js 统一配置请求URL
//----------------------------应用-------------------------------
// 根据id查用户
export function findById(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + '/zwfw/getUserById?id=1',
    method: 'get',
    data
  })
}
// 查用户列表
export function findList() {
  const data = {}
  return fetch({
    url: until.apiPath + 'zwfw/list',
    method: 'get',
    data
  })
}
// 增加用户
export function addUser(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'zwfw/addUser',
    method: 'post',
    data
  })
}
// 修改用户
export function updateUser(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'zwfw/updateUser',
    method: 'post',
    data
  })
}
// 删除用户
export function deleteUser(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'zwfw/deleteUser',
    method: 'get',
    data
  })
}
// 创建应用
export function creatProduction(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'registry/add',
    method: 'POST',
    data
  })
}
// 修改应用
export function modifyProduction(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'registry/update',
    method: 'POST',
    data
  })
}
// 根据id查询
export function appCodeList(obj) {
  const data = obj
  // console.log('data:' + data)
  return fetch({
    url: until.apiPath + 'zwfw/getUserById',
    method: 'GET',
    params: data
  })
}
// 删除应用
export function deletetApp(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'zwfw/deleteUser',
    method: 'GET',
    params: data
  })
}
// 全部应用
export function getAllApi(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'registry/getAll',
    method: 'GET',
    params: data
  })
}
//----------------------------服务-------------------------------
// 服务列表 type (string, optional): 服务类型: 0.已发布服务, 1.已订阅服务， 2.全部服务
export function getService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/list',
    method: 'POST',
    data
  })
}
// 根据apiCode获取服务详情
export function getServiceDetails(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/editView',
    method: 'GET',
    params: data
  })
}
// 禁用服务
export function forbidService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/forbidden',
    method: 'GET',
    params: data
  })
}
// 激活服务
export function recoverService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/recover',
    method: 'GET',
    params: data
  })
}
// 添加路由
export function creatService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/add',
    method: 'POST',
    data
  })
}
// 删除路由
export function deletetService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/delete',
    method: 'GET',
    params: data
  })
}
// 修改路由
export function modifyService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/edit',
    method: 'POST',
    data
  })
}
// 获取所有应用code
export function selectAllAppCode(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'apiRoute/selectAllAppCode',
    method: 'GET',
    params: data
  })
}
// 订阅服务
export function applyService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'appSubApi/add',
    method: 'GET',
    params: data
  })
}
// 取消订阅服务
export function cancelService(obj) {
  const data = obj
  return fetch({
    url: until.apiPath + 'appSubApi/delete',
    method: 'GET',
    params: data
  })
}